package com.lil.shiro.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created by cmazxiaoma on 2017/10/29.
 * everyday is mayday.
 */

@Data
@ApiModel(value = "响应信息", description = "ApiResponse")
public class ApiResponse {
    @ApiModelProperty(name = "code", notes = "响应码", dataType = "Integer", required = true)
    private Integer code;
    @ApiModelProperty(name = "message", notes = "响应信息", dataType = "String", required = true)
    private String message;
    @ApiModelProperty(name = "data", notes = "详情对象", dataType = "String", required = false)
    private Object data;

    public ApiResponse() {
    }


    public ApiResponse(ResultCode resultCode) {
        setCode(resultCode);
        setMessage(resultCode);
    }

    public ApiResponse(ResultCode resultCode, Object data) {
        setCode(resultCode);
        setMessage(resultCode);
        setData(data);
    }

    public void setResultCode(ResultCode resultCode) {
        setCode(resultCode);
        setMessage(resultCode);
    }

    public void setCode(ResultCode resultCode) {
        this.code = resultCode.getCode();
    }

    public void setMessage(ResultCode resultCode) {
        this.message = resultCode.getMsg();
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
